package com.iis.entity;

import java.sql.SQLException;
import java.util.ArrayList;

import com.iis.dao.AgentDAO;

public class Agent extends Person {

	private long agentID;
	private String agentNo;
	private String region;

	public long getAgentID() {
		return agentID;
	}

	public void setAgentID(long agentID) {
		this.agentID = agentID;
	}

	public String getAgentNo() {
		return agentNo;
	}

	public void setAgentNo(String agentNo) {
		this.agentNo = agentNo;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public void save() {
		AgentDAO myAgentDAO = AgentDAO.getInstances();
		try {
			myAgentDAO.save(this);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static ArrayList<Agent> getAll() {
		AgentDAO myAgentDAO = AgentDAO.getInstances();
		return myAgentDAO.getAll();
	}

	public String[] toArray() {
		String[] arr = new String[5];
		arr[0] = String.valueOf(this.getAgentID());
		arr[1] = this.getName();
		arr[2] = this.getRegion();
		return arr;
	}

	public boolean update() {
		AgentDAO myAgentDAO = AgentDAO.getInstances();
		return myAgentDAO.update(this);
	}

}
